<%--
  Created by IntelliJ IDEA.
  User: 33536
  Date: 2022/5/10
  Time: 11:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加权限角色</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ajaxForm.js"></script>

</head>
<script>
    layui.use(['form', 'laydate', 'layer'], function () {
        var form = layui.form, laydate = layui.laydate, layer = layui.layer;
        //监听表单提交
        form.on('submit(formbtn)', function () {
            $("#form1").ajaxSubmit({
                type: "post",
                url: '${pageContext.request.contextPath}/juris/addchare',
                success: function (data) {//添加成功的回调函数
                    var index = parent.layer.getFrameIndex(window.name);//获取Frame索引
                    parent.layer.close(index);//关闭当前frame
                    parent.layui.table.reload("demo");//可以对父窗口进行刷新
                }
            });

        });
        <%--form.on('submit(formBtn)', function () {--%>
        <%--    var formData = new FormData($("#form1")[0]);--%>
        <%--    $.ajax({--%>
        <%--        url:'${pageContext.request.contextPath}/juris/addchare',--%>
        <%--        type : 'POST',--%>
        <%--        data : formData,--%>
        <%--        cache: false,--%>
        <%--        async: false,--%>
        <%--        processData : false,  //必须false才会避开jQuery对 formdata 的默认处理--%>
        <%--        contentType : false,  //必须false才会自动加上正确的Content-Type--%>
        <%--        mimeType:"multipart/form-data",--%>
        <%--        success:function(data){--%>
        <%--            layer.msg('添加成功！',{icon:6,offset:"auto",time:2000});//提示框--%>
        <%--            setTimeout(function(){--%>
        <%--                var index = parent.layer.getFrameIndex(window.name);--%>
        <%--                parent.layer.close(index);//关闭弹出层--%>
        <%--                parent.location.reload();//重新加载父页面表格--%>
        <%--            }, 2100);--%>
        <%--        }--%>
        <%--    })--%>
        <%--    return false;--%>
        <%--});--%>
    });
</script>
<body>
<form class="layui-form" id="form1"  >

    <div class="layui-form-item">
        <label class="layui-form-label">角色名:</label>
        <div class="layui-input-inline">
            <input type="text" name="characterName" class="layui-input" placaholder="请输入角色名" lay-verify="required" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">部门:</label>
        <div class="layui-input-inline">
            <select name="postId" lay-filter="couresId" id="postId">
                <c:forEach items="${pos}" var="poss">
                    <option value="${poss.postId}">${poss.postName}</option>
                </c:forEach>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <button id="formbtn" type="button" lay-submit lay-filter="formbtn" class="layui-btn layui-btn-normal">
                ok
            </button>
        </div>
    </div>



</form>
<script>

</script>



</body>
</html>